﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using ExtAspNet;

public partial class Module_StaffManger_UpLoadFile : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
        Button2.OnClientClick = ActiveWindow.GetHideReference();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (FileUpload1.HasFile)
        {

            if (FileUpload1.ShortFileName.Split('.')[1].ToString() != "xls")
            {
                Alert.ShowInParent("请上传正确的数据模板文件");
                return;
            }


            //限制只能上传excel文件
            string FilePath = "~/Files/StaffData/" + DateTime.Now.ToString("yyyyMMddHHmmss") + StaffName + FileUpload1.ShortFileName;
            FileUpload1.SaveAs(Server.MapPath(FilePath));
            //保存文件,并且将文件的保存路径写入数据库
            PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(FilePath) + ActiveWindow.GetHideReference());
        }
        else
        {
            Alert.ShowInParent("请先选择文件");
        }

    }
}